import api from "@/libs/request";

export const register = (form: any) => {
    return api.post("/platform/account-info/register", form);
};

/**
 * 商户登录接口
 * @param data
 * @query: tenementLoginDto -->  (必须)
 */
export const unionAccountLogin = (data: any) => {
    return api.post("/platform/account-info/login-v1",
        data,
        {
            headers: {"Content-Type": "application/json"},
        });
};

/**
 * 商户自行注册接口
 * @param data
 * @query: accountRegisterDto -->  商户自行注册表单(必须)
 */
export const registerAccount = (data: any) => {
    return api.post("/platform/account-info/oneself/register",
        data,
        {
            headers: {"Content-Type": "application/json"},
        });
};

/**
 * 扫码成功回调,根据code获取制定场景值
 * @query: code --> 微信扫码返回的codo
 */
export const verifyStateResult = (data: any) => {
    return api.get("/platform/account-info/verify/state/result", data);
};

// 根据经纬度返回省市区
export const analysisLatAndLon = (data: any) => {
    return api.get(
        "/account/mini-account-address/analysis/latitude-longitude",
        data,
    );
};

export const signIn = (form: any) => {
    return api.post("/platform/account-info/login", form);
};

export const signInByCode = (form: any) => {
    return api.put("/platform/account-info/login/code", form);
};

// 账号校验
export const checkoutAccount = (data: any) => {
    return api.get("/platform/account-info/checkout/account", data);
};

// 发送一次性验证,后端在common中定义校验类型,有效期统一5分钟,使用即失效,60秒可发送一次
export const getCode = (data?: any) => {
    return api.post("/platform/send-code",
        data,
        {
            headers: {"Content-Type": "application/json"},
        });
};

// 网站应用扫码
export const scanCode = (data: any) => {
    return api.get(`/platform/account-info/scancode`, data);
};

// 根据请求token获取当前用户最新的信息
export const getAccountInfo = () => {
    return api.get("/platform/account-info/info", {});
};

// 发送手机号校验码,验证码有效期5分钟,仅限用户修改个人信息时调用
export const getPhoneCode = (data) => {
    return api.get("/platform/account-info/phone/code/send", data);
};

// 预扫码校验接口,返回state
export const getScanCodeUrl = (data: any) => {
    return api.post("/platform/account-info/pre/account/verify",
        data,
        {
            headers: {"Content-Type": "application/json"},
        });
};

// 手机号换绑
export const changePhone = (data: any) => {
    return api.put("/platform/account-info/phone/change/tie",
        data,
        {
            headers: {"Content-Type": "application/json"},
        });
};

// 修改密码
export const changePassword = (data: any) => {
    return api.put("/platform/account-info/pass/change/tie",
        data,
        {
            headers: {"Content-Type": "application/json"},
        });
};

// 忘记密码 重置密码接口(目前仅限商户账号修改,商户子账号无法修改)
export const forgetPassword = (data: any) => {
    return api.post("/platform/account-info/password-retrieve",
        data,
        {
            headers: {"Content-Type": "application/json"},
        });
};

// 修改密码的时候,校验手机号是都是当前账号
export const verifyThePhone = (data: any) => {
    return api.put("/platform/account-info/verify/data",
        data,
        {
            headers: {"Content-Type": "application/json"},
        });
};

// 验证码校验,校验成功返回凭证码
export const verifyTheCode = (data: any) => {
    return api.put("/platform/send-code/verify/code",
        data,
        {
            headers: {"Content-Type": "application/json"},
        });
};

// 获取指定版本默认值
export const getUniDefaultValue = (uniqueIdentification, version) => {
    return api.get(`/platform/default-value/${uniqueIdentification}/${version}`, {});
};

// 获取指定系统配置
export const getSystemConfig = () => {
    return api.get(`/platform/system-conf/service/config`, {});
};

// 商户申请成为代理
export const applyAgent = (data) => {
    return api.post("/platform/account-info/apply/agent",
        data,
        {
            headers: {
                "Content-Type": "application/json",
            },
        });
};

// 商户进入自己的代理后台
export const getAgentToken = () => {
    return api.get(`/platform/account-info/agent/console`, {});
};

